package cn.com.roy.thread.transdata;

public class ThreadB extends Thread {
    private TransService service;

    public ThreadB(TransService service) {
        this.service = service;
    }

    @Override
    public void run() {
        super.run();
        while (true) {
            System.out.println(Thread.currentThread().getName()+ ": " + service.size());
            if (service.size() == 5) {
                System.out.println("size == 5,线程B要退出了");
                try {
                    throw new InterruptedException();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
